﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/MasterPage.master" AutoEventWireup="true" CodeFile="ThemSanPham.aspx.cs" Inherits="Admin_ThemSanPham" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
<h3>Thêm tài liệu</h3>
    <asp:ListView ID="ListView1" runat="server" DataKeyNames="IDTaiLieu" OnItemInserting="lvCountries_ItemInserting" OnItemInserted="Inserted"
        DataSourceID="SqlDataSource1" EnableModelValidation="True"
        InsertItemPosition="LastItem">
        
        <EditItemTemplate>
            <span style="background-color: #FFCC66;color: #000080;">IDLoaiTL:
            <asp:TextBox ID="IDLoaiTLTextBox" runat="server" 
                Text='<%# Bind("IDLoaiTL") %>' />
            <br />
            TenTL:
            <asp:TextBox ID="TenTLTextBox" runat="server" Text='<%# Bind("TenTL") %>' />
            <br />
            TacGia:
            <asp:TextBox ID="TacGiaTextBox" runat="server" Text='<%# Bind("TacGia") %>' />
            <br />
            MoTa:
            <asp:TextBox ID="MoTaTextBox" runat="server" Text='<%# Bind("MoTa") %>' />
            <br />
            NamPhatHanh:
            <asp:TextBox ID="NamPhatHanhTextBox" runat="server" 
                Text='<%# Bind("NamPhatHanh") %>' />
            <br />
            HinhAnh:
            <asp:TextBox ID="HinhAnhTextBox" runat="server" Text='<%# Bind("HinhAnh") %>' />
            <br />
            DonGia:
            <asp:TextBox ID="DonGiaTextBox" runat="server" Text='<%# Bind("DonGia") %>' />
            <br />
            TaiLieuMoi:
            <asp:TextBox ID="TaiLieuMoiTextBox" runat="server" 
                Text='<%# Bind("TaiLieuMoi") %>' />
            <br />
            ThuTuHienThi:
            <asp:TextBox ID="ThuTuHienThiTextBox" runat="server" 
                Text='<%# Bind("ThuTuHienThi") %>' />
            <br />
            TrangThai:
            <asp:TextBox ID="TrangThaiTextBox" runat="server" 
                Text='<%# Bind("TrangThai") %>' />
            <br />License:
            <asp:TextBox ID="LicenseTextBox" runat="server" Text='<%# Bind("License") %>' />
            <br />IDTaiLieu:
            <asp:Label ID="IDTaiLieuLabel1" runat="server" 
                Text='<%# Eval("IDTaiLieu") %>' />
            <br />
            <asp:Button ID="UpdateButton" runat="server" CommandName="Update" 
                Text="Update" />
            <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" 
                Text="Cancel" />
            <br />
            <br />
            </span>
        </EditItemTemplate>
        <EmptyDataTemplate>
            <span>No data was returned.</span>
        </EmptyDataTemplate>
        <InsertItemTemplate>
        <table class="table_them_sp">
        <tr>
           <td class="trai" style="padding-top: 20px">Loại tài liệu:</td>
            <td class="phai" style="padding-top: 20px"><asp:DropDownList ID="ddlLoaiTLCha" runat="server" AppendDataBoundItems="true"
               DataSourceID="SqlDataSource2"
               DataTextField="TenLoaiTL"
               DataValueField="IDLoaiTL"
               /></td>
        </tr>
        <tr>
            <td class="trai">Tên tài liệu:</td>
            <td class="phai"><asp:TextBox ID="TenTLTextBox" runat="server" Text='<%# Bind("TenTL") %>' /></td>
            </tr>
        <tr>
            <td class="trai">Tác giả:</td>
            <td class="phai"><asp:TextBox ID="TacGiaTextBox" runat="server" Text='<%# Bind("TacGia") %>' /></td>
            </tr>
            <tr>
            <td class="trai">Mô tả:</td>
            <td class="phai"><asp:TextBox TextMode="MultiLine" ID="MoTaTextBox" runat="server" Text='<%# Bind("MoTa") %>'/>
            </td>
                
            </tr>
            <tr>
            <td class="trai">Ngày phát hành:</td>
            <td class="phai"><asp:TextBox ID="NamPhatHanhTextBox" runat="server" 
                Text='<%# Bind("NamPhatHanh") %>' /></td>
            <br />
            </tr>
            <tr>
            <td class="trai">Hình ảnh:</td>
            <td class="phai">
            <asp:FileUpload ID="fuPicture" runat="server"/>
            </td>
            </tr>
            <tr>
            <td class="trai">Đơn giá:</td>
            <td class="phai"><asp:TextBox ID="DonGiaTextBox" runat="server" Text='<%# Bind("DonGia") %>' /></td>
            </tr>
            <tr>
            <td class="trai">Hiển thị tài liệu mới:</td>
            <td class="phai"><asp:DropDownList ID="ddlTaiLieuMoi" runat="server">
            <asp:ListItem Value="1" Text="Hiển thị"></asp:ListItem>
            <asp:ListItem Value="0" Text="Không hiển thị"></asp:ListItem>
            </asp:DropDownList> </td>
            </tr>
            <tr>
            <td class="trai">Thứ tự hiển thị:</td>
            <td class="phai"><asp:TextBox ID="ThuTuHienThiTextBox" runat="server" 
                Text='<%# Bind("ThuTuHienThi") %>' /></td>
            </tr>
            <tr>
            <td class="trai">Trạng thái:</td>
            <td class="phai"><asp:DropDownList ID="ddlTrangThai" runat="server">
            <asp:ListItem Value="1" Text="Còn hàng"></asp:ListItem>
            <asp:ListItem Value="0" Text="Hết hàng"></asp:ListItem>
            </asp:DropDownList>
            </td>
            </tr>
            <tr>
            <td class="trai">License Key:</td>
            <td class="phai"><asp:TextBox ID="LicenseTextBox" runat="server" Text='<%# Bind("License") %>' /></td>
            </tr>
            <tr>
            <td colspan="2" style="padding-left: 300px" class="bo_nut">
            <asp:Button ID="InsertButton" runat="server" CommandName="Insert" CssClass="button" 
                Text="Thêm" />
            <asp:Button ID="Button1" runat="server" CommandName="Insert" OnClick="To_DanhSach" CssClass="button"
                Text="Xem danh sách" />
            <asp:Button ID="CancelButton" runat="server" CommandName="Cancel"   CssClass="button"
                Text="Nhập lại" />
          </td>
           </tr>
            </table>
        </InsertItemTemplate>
     
        <LayoutTemplate>
            <div ID="itemPlaceholderContainer" runat="server" 
                style="font-family: Verdana, Arial, Helvetica, sans-serif;">
                <span runat="server" id="itemPlaceholder" />
            </div>
            <div style="text-align: center;background-color: #FFCC66;font-family: Verdana, Arial, Helvetica, sans-serif;color: #333333;">
            </div>
        </LayoutTemplate>
        <SelectedItemTemplate>
            <span style="background-color: #FFCC66;font-weight: bold;color: #000080;">
            IDLoaiTL:
            <asp:Label ID="IDLoaiTLLabel" runat="server" Text='<%# Eval("IDLoaiTL") %>' />
            <br />
            TenTL:
            <asp:Label ID="TenTLLabel" runat="server" Text='<%# Eval("TenTL") %>' />
            <br />
            TacGia:
            <asp:Label ID="TacGiaLabel" runat="server" Text='<%# Eval("TacGia") %>' />
            <br />
            MoTa:
            <asp:Label ID="MoTaLabel" runat="server" Text='<%# Eval("MoTa") %>' />
            <br />
            NamPhatHanh:
            <asp:Label ID="NamPhatHanhLabel" runat="server" 
                Text='<%# Eval("NamPhatHanh") %>' />
            <br />
            HinhAnh:
            <asp:Label ID="HinhAnhLabel" runat="server" Text='<%# Eval("HinhAnh") %>' />
            <br />
            DonGia:
            <asp:Label ID="DonGiaLabel" runat="server" 
                Text='<%# Eval("DonGia") %>' />
            <br />
            TaiLieuMoi:
            <asp:Label ID="TaiLieuMoiLabel" runat="server" 
                Text='<%# Eval("TaiLieuMoi") %>' />
            <br />
            ThuTuHienThi:
            <asp:Label ID="ThuTuHienThiLabel" runat="server" 
                Text='<%# Eval("ThuTuHienThi") %>' />
            <br />
            TrangThai:
            <asp:Label ID="TrangThaiLabel" runat="server" 
                Text='<%# Eval("TrangThai") %>' />
            <br />
            License:
            <asp:Label ID="LicenseLabel" runat="server" Text='<%# Eval("License") %>' />
            <br />
            IDTaiLieu:
            <asp:Label ID="IDTaiLieuLabel" runat="server" Text='<%# Eval("IDTaiLieu") %>' />
            <br />
<br /></span>
        </SelectedItemTemplate>
    </asp:ListView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"  
        ConflictDetection="CompareAllValues" 
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
        DeleteCommand="DELETE FROM [TaiLieu] WHERE [IDTaiLieu] = @original_IDTaiLieu AND [IDLoaiTL] = @original_IDLoaiTL AND (([TenTL] = @original_TenTL) OR ([TenTL] IS NULL AND @original_TenTL IS NULL)) AND (([TacGia] = @original_TacGia) OR ([TacGia] IS NULL AND @original_TacGia IS NULL)) AND (([MoTa] = @original_MoTa) OR ([MoTa] IS NULL AND @original_MoTa IS NULL)) AND (([NamPhatHanh] = @original_NamPhatHanh) OR ([NamPhatHanh] IS NULL AND @original_NamPhatHanh IS NULL)) AND (([HinhAnh] = @original_HinhAnh) OR ([HinhAnh] IS NULL AND @original_HinhAnh IS NULL)) AND (([DonGia] = @original_DonGia) OR ([DonGia] IS NULL AND @original_DonGia IS NULL)) AND (([TaiLieuMoi] = @original_TaiLieuMoi) OR ([TaiLieuMoi] IS NULL AND @original_TaiLieuMoi IS NULL)) AND (([ThuTuHienThi] = @original_ThuTuHienThi) OR ([ThuTuHienThi] IS NULL AND @original_ThuTuHienThi IS NULL)) AND (([TrangThai] = @original_TrangThai) OR ([TrangThai] IS NULL AND @original_TrangThai IS NULL)) AND (([License] = @original_License) OR ([License] IS NULL AND @original_License IS NULL))" 
        InsertCommand="INSERT INTO [TaiLieu] ([IDLoaiTL], [TenTL], [TacGia], [MoTa], [NamPhatHanh], [HinhAnh], [DonGia], [TaiLieuMoi], [ThuTuHienThi], [TrangThai], [License]) VALUES (@IDLoaiTL, @TenTL, @TacGia, @MoTa, @NamPhatHanh, @HinhAnh, @DonGia, @TaiLieuMoi, @ThuTuHienThi, @TrangThai, @License)" 
        OldValuesParameterFormatString="original_{0}" 
     
        
        UpdateCommand="UPDATE [TaiLieu] SET [IDLoaiTL] = @IDLoaiTL, [TenTL] = @TenTL, [TacGia] = @TacGia, [MoTa] = @MoTa, [NamPhatHanh] = @NamPhatHanh, [HinhAnh] = @HinhAnh, [DonGia] = @DonGia, [TaiLieuMoi] = @TaiLieuMoi, [ThuTuHienThi] = @ThuTuHienThi, [TrangThai] = @TrangThai, [License] = @License WHERE [IDTaiLieu] = @original_IDTaiLieu AND [IDLoaiTL] = @original_IDLoaiTL AND (([TenTL] = @original_TenTL) OR ([TenTL] IS NULL AND @original_TenTL IS NULL)) AND (([TacGia] = @original_TacGia) OR ([TacGia] IS NULL AND @original_TacGia IS NULL)) AND (([MoTa] = @original_MoTa) OR ([MoTa] IS NULL AND @original_MoTa IS NULL)) AND (([NamPhatHanh] = @original_NamPhatHanh) OR ([NamPhatHanh] IS NULL AND @original_NamPhatHanh IS NULL)) AND (([HinhAnh] = @original_HinhAnh) OR ([HinhAnh] IS NULL AND @original_HinhAnh IS NULL)) AND (([DonGia] = @original_DonGia) OR ([DonGia] IS NULL AND @original_DonGia IS NULL)) AND (([TaiLieuMoi] = @original_TaiLieuMoi) OR ([TaiLieuMoi] IS NULL AND @original_TaiLieuMoi IS NULL)) AND (([ThuTuHienThi] = @original_ThuTuHienThi) OR ([ThuTuHienThi] IS NULL AND @original_ThuTuHienThi IS NULL)) AND (([TrangThai] = @original_TrangThai) OR ([TrangThai] IS NULL AND @original_TrangThai IS NULL)) AND (([License] = @original_License) OR ([License] IS NULL AND @original_License IS NULL))">
        <DeleteParameters>
            <asp:Parameter Name="original_IDTaiLieu" Type="Int32" />
            <asp:Parameter Name="original_IDLoaiTL" Type="Int32" />
            <asp:Parameter Name="original_TenTL" Type="String" />
            <asp:Parameter Name="original_TacGia" Type="String" />
            <asp:Parameter Name="original_MoTa" Type="String" />
            <asp:Parameter Name="original_NamPhatHanh" DbType="Date" />
            <asp:Parameter Name="original_HinhAnh" Type="String" />
            <asp:Parameter Name="original_DonGia" Type="Decimal" />
            <asp:Parameter Name="original_TaiLieuMoi" Type="Int32" />
            <asp:Parameter Name="original_ThuTuHienThi" Type="Int32" />
            <asp:Parameter Name="original_TrangThai" Type="Int32" />
            <asp:Parameter Name="original_License" Type="String" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="IDLoaiTL" Type="Int32" />
            <asp:Parameter Name="TenTL" Type="String" />
            <asp:Parameter Name="TacGia" Type="String" />
            <asp:Parameter Name="MoTa" Type="String" />
            <asp:Parameter Name="NamPhatHanh" DbType="Date" />
            <asp:Parameter Name="HinhAnh" Type="String" />
            <asp:Parameter Name="DonGia" Type="Decimal" />
            <asp:Parameter Name="TaiLieuMoi" Type="Int32" />
            <asp:Parameter Name="ThuTuHienThi" Type="Int32" />
            <asp:Parameter Name="TrangThai" Type="Int32" />
            <asp:Parameter Name="License" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="IDLoaiTL" Type="Int32" />
            <asp:Parameter Name="TenTL" Type="String" />
            <asp:Parameter Name="TacGia" Type="String" />
            <asp:Parameter Name="MoTa" Type="String" />
            <asp:Parameter Name="NamPhatHanh" DbType="Date" />
            <asp:Parameter Name="HinhAnh" Type="String" />
            <asp:Parameter Name="DonGia" Type="Decimal" />
            <asp:Parameter Name="TaiLieuMoi" Type="Int32" />
            <asp:Parameter Name="ThuTuHienThi" Type="Int32" />
            <asp:Parameter Name="TrangThai" Type="Int32" />
            <asp:Parameter Name="License" Type="String" />
            <asp:Parameter Name="original_IDTaiLieu" Type="Int32" />
            <asp:Parameter Name="original_IDLoaiTL" Type="Int32" />
            <asp:Parameter Name="original_TenTL" Type="String" />
            <asp:Parameter Name="original_TacGia" Type="String" />
            <asp:Parameter Name="original_MoTa" Type="String" />
            <asp:Parameter Name="original_NamPhatHanh" DbType="Date" />
            <asp:Parameter Name="original_HinhAnh" Type="String" />
            <asp:Parameter Name="original_DonGia" Type="Decimal" />
            <asp:Parameter Name="original_TaiLieuMoi" Type="Int32" />
            <asp:Parameter Name="original_ThuTuHienThi" Type="Int32" />
            <asp:Parameter Name="original_TrangThai" Type="Int32" />
            <asp:Parameter Name="original_License" Type="String" />
        </UpdateParameters>
    </asp:SqlDataSource>

      <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
        SelectCommand="SELECT [IDLoaiTL],[TenLoaiTL] FROM [LoaiTaiLieu]"></asp:SqlDataSource>

</asp:Content>

